package cn.dxj1016.lesson02;

import cn.dxj1016.lesson02.utils.JdbcUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class TestUpdate {
    public static void main(String[] args) {
        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;
        try {
            connection = JdbcUtils.getConnenction();//获取数据库连接
            statement = connection.createStatement();//获得SQL的执行对象
            String sql = "UPDATE users SET `NAME`='dxj1016' WHERE id=5";
            int i = statement.executeUpdate(sql);
            if (i > 0) {
                System.out.println("修改成功");

            }

        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            JdbcUtils.release(connection,statement,resultSet);
        }

    }
}
